package com.his.his_system.controller.DataStatisticsController;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.his.his_system.domain.DzmHisCarePkg;
import com.his.his_system.domain.DzmHisCareRefundlog;
import com.his.his_system.service.DzmHisCarePaylogService;
import com.his.his_system.service.DzmHisCarePkgService;
import com.his.his_system.service.DzmHisCareRefundlogService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 收支统计
 */
@RestController
@RequestMapping("/IncomeAndExpenses")
public class IncomeAndExpensesController {

      /**
       * 患者信息表
       */
      @Resource
      private DzmHisCarePkgService dzmHisCarePkgService;

      /**
       * 退费信息表
       */
      @Resource
      private DzmHisCareRefundlogService dzmHisCareRefundlogService;

      /**
       * 支付收费记录
       */
      @Resource
      private DzmHisCarePaylogService dzmHisCarePaylogService;

      /**
       * 全部缴费信息
       * @return
       */
      private  static final int PAGENUM=1;   //默认分页第一页

      private static  final int PAGESIZE=3;  //页面显示条数

      @GetMapping("/getInfo")
      PageInfo<DzmHisCarePkg> getInfo(){

//            设置分页
            PageHelper.startPage(PAGENUM,PAGESIZE);

            PageInfo<DzmHisCarePkg> page = new PageInfo<DzmHisCarePkg>(dzmHisCarePkgService.getInfo());

            return page;
      }

      /**
       * 分页查询
       */
      @PostMapping("/paging")
      PageInfo<DzmHisCarePkg> paging(Integer pageNum){

//            设置分页
            PageHelper.startPage(pageNum,PAGESIZE);

            PageInfo<DzmHisCarePkg> page = new PageInfo<DzmHisCarePkg>(dzmHisCarePkgService.getInfo());

            return page;
      }


      /**
       * 获取全部退费信息
       */
      @GetMapping("/returnPremium")
      List<DzmHisCareRefundlog> getReturnPremium(){
            List<DzmHisCareRefundlog> result = dzmHisCareRefundlogService.getReturnPremium();
            return result;
      }

      /**
       * 获取现金收入金额
       */
      @GetMapping("/getCash")
      String getCash(){

            return  dzmHisCarePaylogService.getCash();

      }


      /**
       * 获取微信收入金额
       */
      @GetMapping("/getWeChat")
      String getWeChat(){

            return  dzmHisCarePaylogService.getWeChat();

      }


      /**
       * 获取支付宝收入金额
       */
      @GetMapping("/getAlipay")
      String getAlipay(){

            return  dzmHisCarePaylogService.getAlipay();

      }

      /**
       * 获取全部费用
       */
      @GetMapping("/lumpSumExpenses")
       String lumpSumExpenses(){

            return  dzmHisCarePaylogService.lumpSumExpenses();
      }

      /**
       * 获取退费总额
       */
      @GetMapping("/totalRefund")
      String totalRefund(){

            return  dzmHisCareRefundlogService.totalRefund();
      }

      /**
       * 查询
       */
      @PostMapping("queryInfo")
      PageInfo<DzmHisCarePkg> query(Integer pageNum, String chargetype,String chargestatus,String startDate,String endDate){

//            设置分页
            PageHelper.startPage(pageNum,PAGESIZE);

            PageInfo<DzmHisCarePkg> page = new PageInfo<DzmHisCarePkg>(dzmHisCarePkgService.queryInfo(chargetype,chargestatus,startDate,endDate));

            return page;
      }



}
